function TaoMoiUser(loai)
{
    cmd_New_User([
     {name: 'loai', value: '' + loai + ''}   
    ]
        );  
}
function ThoatUser(loai)
{
    cmd_Thoat([
     {name: 'loai', value: '' + loai + ''}   
    ]
        );  
}

function Save_User_Click(isadmin)
{
    
    
    var right=(isadmin?'A':'C');
    var game1=true;
    var game2=true;
    var game3=true;
     game1=document.getElementById("cbGame1").checked;
    game2=document.getElementById("cbGame2").checked;
    game3=document.getElementById("cbGame3").checked;
    
    var EditInfo=false;
    if(isadmin)
        EditInfo=document.getElementById("cbEditInfo").checked;
    var thongKeTK=document.getElementById("cbthongKeTK").checked;
    var tkDoanhThu=document.getElementById("cbtkDoanhThu").checked;
    var TKNapTien=document.getElementById("cbTKNapTien").checked;
    
    var TongCashout=document.getElementById("cbTongCashout").checked;
    var ThongKeDoanhThu=document.getElementById("cbThongKeDoanhThu").checked;
    var ThongKeDoanhThuBit=document.getElementById("cbThongKeDoanhThuBit").checked;
    var ThongKeDoanhThuBac=document.getElementById("cbThongKeDoanhThuBac").checked;
    var ThongKeKhac=document.getElementById("cbThongKeKhac").checked;
    
  
    
    var TongBit=document.getElementById("cbTongBit").checked;
    var TongBac=document.getElementById("cbTongBac").checked;
  
    var DoanhThu=document.getElementById("cbDoanhThu").checked;
    var ThongKeTheoGame=false;
    var NganLuong=false;
    var Epay=false;
    if(isadmin)
        {
        ThongKeTheoGame=document.getElementById("cbThongKeTheoGame").checked;
         Epay=document.getElementById("cbEpay").checked;
            NganLuong=document.getElementById("cbNganLuong").checked;
        }
    
   
    
    
    Save_Users(
            [
                {name: 'right', value: '' + right + ''}
                ,{name: 'game1', value: '' + game1 + ''}
                ,{name: 'game2', value: '' + game2 + ''}
                ,{name: 'game3', value: '' + game3 + ''}
                ,{name: 'editinfo', value: '' + EditInfo + ''}
                ,{name: 'thongketk', value: '' + thongKeTK + ''}
                ,{name: 'tkdoanhthu', value: '' + tkDoanhThu + ''}
                
                ,{name: 'TKNapTien', value: '' + TKNapTien + ''}
                ,{name: 'TongCashOut', value: '' + TongCashout + ''}
                ,{name: 'ThongKeDoanhThu', value: '' + ThongKeDoanhThu + ''}
                ,{name: 'ThongKeDoanhThuBit', value: '' + ThongKeDoanhThuBit + ''}
                ,{name: 'ThongKeDoanhThuBac', value: '' + ThongKeDoanhThuBac + ''}
                ,{name: 'ThongKeKhac', value: '' + ThongKeKhac + ''}
                ,{name: 'TongBit', value: '' + TongBit + ''}
                ,{name: 'TongBac', value: '' + TongBac + ''}
                
                ,{name: 'Epay', value: '' + Epay + ''}
                ,{name: 'NganLuong', value: '' + NganLuong + ''}
                ,{name: 'DoanhThu', value: '' + DoanhThu + ''}
                ,{name: 'ThongKeTheoGame', value: '' + ThongKeTheoGame + ''}
            ]
        );
        
}
function Update_Users_Click(id)
{
    Update_UserReport([{name: 'id', value: '' + id + ''}]);
        
}
function Delete_Users_Click(id,msg)
{
    var x=confirm(msg);
    if(x==true)
        {
            Delete_UserReport([{name: 'id', value: '' + id + ''}]);
        }
    
        
}
function CapNhatDanhSachTaiKhoan()
{
   var arrchecks = new Array();
    $("input:checkbox[name='checkIds']").each(
            function () {
                arrchecks.push(this.getAttribute("id")+"_"+this.checked);
            });
    Update_TrangThai_NguoiDung(
            [{name: 'TrangThai', value: '' + arrchecks + ''}]
        );
}

function DangNhap_keyPress(event)
{
    if(event.keyCode===13)
        {
            
             var txtMa= document.getElementById("txtUserID");
            var txtMatKhau= document.getElementById("txtPassword");

            DangNhap([{name: 'Ma', value: '' + txtMa.value + ''},{name: 'MatKhau', value: '' + txtMatKhau.value + ''}]);
            return;
        }
   
}
function DangNhap_Click()
    {
       
        var txtMa= document.getElementById("txtUserID");
        var txtMatKhau= document.getElementById("txtPassword");

        DangNhap([{name: 'Ma', value: '' + txtMa.value + ''},{name: 'MatKhau', value: '' + txtMatKhau.value + ''}]);
        return;
    }
function ThayDoiMatKhau_Click()
    {
       
        
        var txtMatKhau= document.getElementById("txtPassword");
        var txtMatKhauMoi= document.getElementById("txtNewPassword");
        var txtNhapLaiMatKhauMoi= document.getElementById("txtPrNewPassword");

        ThayDoiMatKhau([
            {name: 'MatKhau', value: '' + txtMatKhau.value + ''}
            ,{name: 'MatKhauMoi', value: '' + txtMatKhauMoi.value + ''}
            ,{name: 'NhapLaiMatKhauMoi', value: '' + txtNhapLaiMatKhauMoi.value + ''}
        ]);
        return;
    }
   
   

$('#sky-form input:checkbox').click(
 function(e){
   alert($(this).is(':checked'));
 }
);
 $(document).ready(function() {
    $('#cbtkDoanhThu').change(function() {
        if($('#cbtkDoanhThu').is(":checked"))
       {
           $('#cbTKNapTien').attr('checked','checked');
           $('#cbTongCashout').attr('checked','checked');
           $('#cbThongKeDoanhThu').attr('checked','checked');
           $('#cbThongKeDoanhThuBit').attr('checked','checked');
           $('#cbThongKeDoanhThuBac').attr('checked','checked');
           $('#cbDoanhThu').attr('checked','checked');
       }
       else
        {
           $('#cbTKNapTien').removeAttr('checked');
           $('#cbTongCashout').removeAttr('checked');
           $('#cbThongKeDoanhThu').removeAttr('checked');
           $('#cbThongKeDoanhThuBit').removeAttr('checked');
           $('#cbThongKeDoanhThuBac').removeAttr('checked');
           $('#cbDoanhThu').removeAttr('checked');
        }

    });
     $('#cbThongKeDoanhThu').change(function() {
        if($('#cbThongKeDoanhThu').is(":checked"))
        {
            $('#cbThongKeDoanhThuBit').attr('checked','checked');
           $('#cbThongKeDoanhThuBac').attr('checked','checked');
        }
        else
            {
                  $('#cbThongKeDoanhThuBit').removeAttr('checked');
                $('#cbThongKeDoanhThuBac').removeAttr('checked');
            }
     });
     $('#cbThongKeKhac').change(function() {
          if($('#cbThongKeKhac').is(":checked"))
            {
                 $('#cbTongBac').attr('checked','checked');
                 $('#cbTongBit').attr('checked','checked');
            }
            else
                {
                     $('#cbTongBac').removeAttr('checked');
                    $('#cbTongBit').removeAttr('checked');
                }
     });
    

});